package com.wangan.wanganpush.utils;

import com.wangan.wanganpush.dao.ParamDao;
import com.wangan.wanganpush.model.Parameter;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

@Service
public class AtomicValue {

    @Resource
    ParamDao paramDao;

    private static AtomicInteger atuo =null;

    public void  AtomicValueInit(){
        List<Parameter> all = paramDao.findAll();
        if(all != null && all.size() > 0){
            atuo =new AtomicInteger(all.get(0).getSeqNum());
        }else{
            atuo =new AtomicInteger(1);
        }
    }


    public Integer getAtuo() {
        return atuo.getAndIncrement();
    }

    public void setAtuo(AtomicInteger atuo) {
        this.atuo = atuo;
    }
}
